package presenters;

import java.sql.ResultSet;

import model.ConnectionManager;
import model.IPresenter;
import views.RevenueReportPanel;

public class RevenueReportPresenter extends IPresenter {
	private RevenueReportPanel myPanel;
	
	public RevenueReportPresenter(RevenueReportPanel panel) {
		super();
		myPanel = panel;
	}
	
	public void generateReport() {
		System.out.println("Generate Revenue Report");
		
		String sql = 
		"SELECT "
		+ "VIN AS `Vehicle ID Num`, "
		+ "TYPE AS `Type`, "
		+ "MDL_NM AS `Car Model`, "
		+ "SUM(EST_COST) AS `Reservation Revenue`, "
		+ "SUM(LATE_FEES) AS `Late Fees Revenue` "
		+ "FROM " + ConnectionManager.GROUP+ ".CAR LEFT JOIN " + ConnectionManager.GROUP+ ".RESERVATION ON (VIN = RNT_VIN) "
		+ "WHERE DATE(PKUP_DTTM) >= SUBDATE(CURDATE(), INTERVAL 3 MONTH) "
		+ "GROUP BY RNT_VIN;";

		ResultSet rs = executeSQLQuery(sql);
		
		myPanel.addData(rs);
	}
}
